package com.xbao.controller;

import com.xbao.core.component.page.Pagination;
import com.xbao.core.http.CommRequest;
import com.xbao.core.http.CommResult;
import com.xbao.model.req.NoticeReq;
import com.xbao.model.req.SubjectReq;
import com.xbao.model.vo.NoticeVo;
import com.xbao.service.NoticeSerivce;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by qingshengzheng on 18/11/13.
 */
@Api(value = "/notice", tags = "notice")
@RequestMapping(value = "notice")
@Controller
@EnableAutoConfiguration
public class NoticeController  extends BaseController{
    @Resource
    private NoticeSerivce noticeSerivce;
    @ApiOperation(value = "addNotice", notes = "addNotice")
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    @ResponseBody
    public Object addNotice(@RequestBody CommRequest<NoticeReq> balanceTypeCommRequest) {
        noticeSerivce.addNotice(balanceTypeCommRequest.getData());
        return result();
    }
    @ApiOperation(value = "detailNotice", notes = "detailNotice")
    @RequestMapping(value = "/detail",method = RequestMethod.POST)
    @ResponseBody
    public CommResult detailNotice(@RequestBody CommRequest<NoticeReq> balanceTypeCommRequest) {
        NoticeVo vo= noticeSerivce.detailNotice(balanceTypeCommRequest.getData().getId());
        return new CommResult<NoticeVo>(vo);
    }
    @ApiOperation(value = "deleteNotice", notes = "deleteNotice")
    @RequestMapping(value = "/delete",method = RequestMethod.POST)
    @ResponseBody
    public Object deleteNotice(@RequestBody CommRequest<NoticeReq> balanceTypeCommRequest) {
        noticeSerivce.deleteNotice(balanceTypeCommRequest.getData().getId());
        return result();
    }
    @ApiOperation(value = "queryList", notes = "queryList")
    @RequestMapping(value = "/list",method = RequestMethod.POST)
    @ResponseBody
    public CommResult queryList(@RequestBody CommRequest<NoticeReq> balanceTypeCommRequest) {
       List<NoticeVo> vos= noticeSerivce.queryNoticeList(balanceTypeCommRequest);
        return new CommResult<List<NoticeVo>>(vos);
    }




    @ApiOperation(value = "update", notes = "update")
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    @ResponseBody
    public CommResult update(@RequestBody CommRequest<NoticeReq> balanceTypeCommRequest) {
        noticeSerivce.updateNotice(balanceTypeCommRequest.getData());
        return new CommResult<List<NoticeVo>>(null);
    }
}
